#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
	int maxArea(vector<int>& height) {
		int left = 0, right = height.size() - 1;
		int maxAera = -1;
		while (left < right) {
			int aera = min(height[left], height[right])*(right-left);
			maxAera = max(aera, maxAera);
			if (height[left] < height[right])
				left++;
			else
				right--;
		}
		return maxAera;
	}
};

int main() {
	vector<int> arr = { 1,8,6,2,5,4,8,3,7 };
	Solution s;
	cout << s.maxArea(arr) << endl;
}